<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>拦截用法示例</title>
</head>

<body>
    <script src="https://cdn.bootcdn.net/ajax/libs/Mock.js/1.0.1-beta3/mock-min.js"></script>
    <div class="box">
        展示内容:<div id="content"></div>
    </div>
    <script>



        Mock.mock('www.haizhi.com', {
            "user|2-5": [{ //2-5组数据
                'name': '@cname', //中文名称
                'age|1-100': 100, //100以内随机整数
            }]
        });
        Mock.setup({
            timeout: '200-600'
        })
        var xhr = new XMLHttpRequest();
        xhr.open("get", "www.haizhi.com", true);
        xhr.send(null);

        xhr.onreadystatechange = function () {
            if (xhr.readyState == 4 && xhr.status == 200) {
                y = xhr.responseText;
                x = document.getElementById("content");
                x.innerHTML = y;
                console.table(y)

            }
        }


    </script>
</body>

</html>